<?php	
	// Interface function	
	function oh_module_xls($tokens) {		
		global $oh_object_xls;
		return $oh_object_xls;
	} 

	// Option file required
	require_once(dirname(__FILE__)."/Excel/reader.php");
	
	// Main class of module
	class oh_class_xls {
		public $data = array();
		function oh_class_xls() {
		}
		function get($filename) {
			$data = new Spreadsheet_Excel_Reader();
			$data->setOutputEncoding('CP1251');
			$data->read($filename);

			$this->data[] = $data;

			return oh_this();
		}
		function load($filename) {
			return $this->get($filename);
		}
		function cell($cell) {
			$cell = trim($cell);
			$cell = explode(":",$cell);
			if (count($cell)==1) {
				$coord = $this->coord($cell[0]);
				return $coord;
			}
			//return 
		}
		function coord($cell) {
			$cell = strtoupper($cell);
			preg_match("/^[A-Z]+/",$cell,$x);
			preg_match("/[0-9]+$/",$cell,$y);
			
			$tempx = trim($x); 
			$x = 0;
			for($i=0;$i<strlen($tempx);$i++) {
				oh_dump(ord($tempx{$i}));
			}
			
			return array("x"=>$x,"y"=>$y);
		}
		
		function info() {
			echo 'xls:module:info';
		}
	}
	
	// Main object of module
	global $oh_object_xls;
	$oh_object_xls = new oh_class_xls();
?>
